<template>
  <a-card :bordered='false'>
    <!-- 查询区域 -->
    <search ref='search' :config='searchConfig' @search='search' @getHeight='getHeight' />
    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        :border='true'
        :resizable='true'
        :showOverflow='true'
        size='mini'
        :loading='loading'
        :height='pageHeight-seachHeight-94'
        :align='left'
        :columns='columns'
        :data='dataSource'
        :toolbar-config='tableToolbar'
        :checkbox-config="checkboxConfig"
        v-bind='vexConfig'
        @checkbox-change='selectChangeEvent'
        @checkbox-all='selectChangeEvent'
      >
        <template #toolbar_buttons>
          <div class='table-operator'>
            <a-button v-has="'proSalePlace:add'" @click='handleAdd'>新增</a-button>
            <a-button v-has="'proSalePlace:delete'" @click='batchDel'>删除</a-button>
            <a-button v-has="'proSalePlace:synchronization'"  @click=''>同步</a-button>
            <a-button v-has="'proSalePlace:export'"  @click="downExportXls('market_scope')">导出</a-button>
            <a-button v-has="'proSalePlace:export'"  @click="downExportXls('market_org_scope')">组织导出</a-button>
            <a-button v-has="'proSalePlace:export'"  @click="downExportXls('market_cust_scope')">客户导出</a-button>
          </div>
        </template>
        <template #detail='{ row,rowIndex }'>
          <a @click='handleDetail(row)'>{{ row.goodsCode }}</a>
        </template>
        <template #date='{ row,rowIndex }'>
          {{ row.startDate }} ~ {{ row.endDate }}
        </template>
        <template #action='{ row }'>
          <a v-has="'proSalePlace:update'" @click='handleEdit(row)'>编辑</a>
          <a-divider type='vertical' />
          <a v-has="'business:log'" href='javascript:;' @click='handleBusiness("销售范围",row)'>日志</a>
        </template>
        <template #pager>
          <vxe-pager
            :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
            :currentPage.sync='ipagination.current'
            :page-size.sync='ipagination.pageSize'
            :total='ipagination.total'
            :pageSizes='ipagination.pageSizeOptions'
            @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>
    <!-- 表单区域 -->
    <!--    <materialModal ref="modalForm" @ok="modalFormOk"></materialModal>-->
    <proSalePlaceModal ref='modalForm'  @ok="modalFormOk"></proSalePlaceModal>
    <business-log ref='businessLog'></business-log>
  </a-card>
</template>

<script>
import { PageListMixin } from '@/mixins/PageListMixin'
import { getAction } from '@/api/manage'
import proSalePlaceModal from './modules/ProSalePlaceModal.vue'
//高级查询modal需要参数

export default {
  name: 'carModelList',
  mixins: [PageListMixin],
  components: {
    proSalePlaceModal
  },
  // priceAdd
  data() {
    return {
      description: '商品销售范围',
      //字典数组缓存
      sexDictOptions: [],
      importExcelUrl: `${window._CONFIG['domianURL']}/test/cn-formDemo/importExcel`,
      searchConfig: [
        {
          // label:'订单编号',
          type: 'input',
          name: 'goodsCode',
          placeholder: '商品编号'
        },
        {
          type: 'input',
          name: 'goodsName',
          placeholder: '商品名称'
        },
        {
          type: 'input',
          name: 'classifyName',
          placeholder: '商品分类'
        }
      ],
      //列定义  表格改这儿
      columns: [
        { type: 'checkbox', width: 60, fixed: 'left' },
        {
          fixed: 'left',
          title: '商品编号',
          minWidth: 100,
          field: 'goodsCode',
          slots: { default: 'detail' }
        },
        {
          title: '商品名称',
          minWidth: 100,
          field: 'goodsName'
        },
        {
          title: '商品分类',
          minWidth: 100,
          field: 'classifyName'
        },
        {
          title: '创建人',
          minWidth: 100,
          field: 'createName'
        },
        {
          title: '创建时间',
          minWidth: 100,
          field: 'createTime'
        },
        {
          title: '更新人',
          minWidth: 100,
          field: 'updateName'
        },
        {
          title: '更新时间',
          minWidth: 100,
          field: 'updateTime'
        },
        {
          title: '操作',
          field: 'action',
          fixed: 'right',
          minWidth: 120,
          slots: {
            default: 'action'
          }
        }
      ],
      url: {
        list: window._CONFIG['domianURL'] + '/goodssalesscope/cnGoodsSalesScope/findPageList',
        detail: window._CONFIG['domianURL'] + '/goodssalesscope/cnGoodsSalesScope/getInfo',
        deleteBatch: window._CONFIG['domianURL'] + '/goodssalesscope/cnGoodsSalesScope/deleteBatch',
        startOrStopUrl: window._CONFIG['domianURL'] + '/material/startOrStop',
      }

    }
  },
  methods: {
    startorstop: function(status) {
      if (!this.url.startOrStopUrl) {
        this.$message.error('请设置url启用停用!')
        return
      }
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！')
        return
      } else {
        var ids = ''
        for (var a = 0; a < this.selectedRowKeys.length; a++) {
          ids += this.selectedRowKeys[a] + ','
        }
        var that = this
        this.$confirm({
          title: '确认修改',
          content: '是否修改选中数据?',
          onOk: function() {
            that.loading = true
            getAction(that.url.startOrStopUrl, { ids: ids, status: status }).then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.loadData()
                that.onClearSelected()
              } else {
                that.$message.warning(res.message)
              }
            }).finally(() => {
              that.loading = false
            })
          }
        })
      }
    },

  },
  created() {

  }

}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
